package com.peking.donations.plugins.pay.wx.utils;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * Created by YGR on 16/3/4.
 */
public class ConfigureFactory {

    private ConfigureFactory() {

    }

    private static ConfigureFactory configureFactory = new ConfigureFactory();

    public static ConfigureFactory getInstance() {
        return configureFactory;
    }

    private static Map<String, Configure> configureMap = Maps.newConcurrentMap();

    public Configure getConfigure(String appId) throws WxpayException {
        Configure configure = configureMap.get(appId);
        if (null == configure) {
            throw new WxpayException("找不到appID=" + appId + " 的公众号配置");
        }
        return configure;
    }

    public void putConfigure(Configure configure) {
        configureMap.put(configure.getAppID(), configure);
    }

}
